package com.wangshouyu.mp.menu;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @author 王守钰
 * @date 2020年12月06日 22:10:27
 * @description: 微信按钮
 */
public class Button implements Serializable {

    /**
     * 按钮类型
     */
    private String type;

    /**
     * 按钮名称
     */
    private String name;

    /**
     * click等点击类型必须
     */
    private String key;

    /**
     * 跳转地址
     */
    private String url;

    /**
     * 小程序appId
     */
    @SerializedName(value = "appid")
    @JsonProperty(value = "appid")
    @JSONField(name = "appid")
    private String appId;

    /**
     * 小程序跳转地址
     */
    @SerializedName(value = "pagepath")
    @JsonProperty(value = "pagepath")
    @JSONField(name = "pagepath")
    private String pagePath;

    /**
     * 素材id
     */
    @SerializedName(value = "media_id")
    @JsonProperty(value = "media_id")
    @JSONField(name = "media_id")
    private String mediaId;

    /**
     * 子按钮
     */
    @SerializedName(value = "sub_button")
    @JsonProperty(value = "sub_button")
    @JSONField(name = "sub_button")
    private List<Button> subButton;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getPagePath() {
        return pagePath;
    }

    public void setPagePath(String pagePath) {
        this.pagePath = pagePath;
    }

    public List<Button> getSubButton() {
        return subButton;
    }

    public void setSubButton(List<Button> subButton) {
        this.subButton = subButton;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Button button = (Button) o;
        return Objects.equals(type, button.type) &&
                Objects.equals(name, button.name) &&
                Objects.equals(key, button.key) &&
                Objects.equals(url, button.url) &&
                Objects.equals(appId, button.appId) &&
                Objects.equals(pagePath, button.pagePath) &&
                Objects.equals(subButton, button.subButton);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, name, key, url, appId, pagePath, subButton);
    }

    @Override
    public String toString() {
        return "Button{" +
                "type='" + type + '\'' +
                ", name='" + name + '\'' +
                ", key='" + key + '\'' +
                ", url='" + url + '\'' +
                ", appId='" + appId + '\'' +
                ", pagePath='" + pagePath + '\'' +
                ", subButton=" + subButton +
                '}';
    }
}
